/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.c0910g.DAO;

import com.myapp.c0910g.entity.ObjectData;
import com.myapp.c0910g.entity.PaymentDetails;
import com.myapp.c0910g.entity.PaymentDetailsFacade;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author BachLe
 */
public class PaymentDetailsDAO {
    PaymentDetailsFacade paymentDetailsFacade = lookupPaymentDetailsFacadeBean();

    private PaymentDetailsFacade lookupPaymentDetailsFacadeBean() {
        try {
            Context c = new InitialContext();
            return (PaymentDetailsFacade) c.lookup("java:global/RadioCabsProject/RadioCabsProject-ejb/PaymentDetailsFacade!com.myapp.c0910g.entity.PaymentDetailsFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<ObjectData> getUserDueDate(){
        return paymentDetailsFacade.getAllUser_CheckBan_SendEmailByStatus();
    }

    public List<PaymentDetails> getAllUser(){
        return this.paymentDetailsFacade.findAll();
    }

    public void addPaymentDetails(PaymentDetails PayDetails){
       paymentDetailsFacade.create(PayDetails);
    }

    public void editPaymentDetails(PaymentDetails PayDetails){
       paymentDetailsFacade.edit(PayDetails);
    }

    public void deletePaymentDetails(PaymentDetails PayDetails){
       paymentDetailsFacade.remove(PayDetails);
    }

    public PaymentDetails findPaymentDetailsById(Integer id){
        return paymentDetailsFacade.find(id);
    }

    public PaymentDetails findPayDetailByUserId(Integer id){
        return paymentDetailsFacade.getPaymentDetailsByUserID(id);
    }

    public List<PaymentDetails> findAllListing(){
        return paymentDetailsFacade.getAllRecordOfListing();
    }

    public List<PaymentDetails> findAllDriver(){
        return paymentDetailsFacade.getAllRecordOfDriver();
    }

    public List<PaymentDetails> findAllAdvertise(){
        return paymentDetailsFacade.getAllRecordOfAdvertise();
    }
}
